﻿using MediatR;
using SupplyChain.Domain.Entities;
using SupplyChain.Infrastructure.Interface;
using SupplyChain.Write.API.Application.Command.Goods;

namespace SupplyChain.Write.API.Application.CommandHandler.Goods
{
    public class GetGoodsHandler : IRequestHandler<GetGoodsCommand, List<GoodsInfo>>
    {
        private readonly IBaseRepository<GoodsInfo> repository;

        public GetGoodsHandler(IBaseRepository<GoodsInfo> repository)
        {
            this.repository = repository;
        }
        public async Task<List<GoodsInfo>> Handle(GetGoodsCommand request, CancellationToken cancellationToken)
        {
            List<GoodsInfo> goods = await repository.GetByWhereAsync(x=>!x.IsDel);
            return await Task.FromResult(goods);
        }
    }
}
